<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="multifile-example.html" />
<link rel="prev" href="module-multifile.html" />
<link rel="parent" href="module-multifile.html" />
<link rel="next" href="multifile-example.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>7.9.1 MultiFile Objects </title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="7.9 multifile  "
  href="module-multifile.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="7.9 multifile  "
  href="module-multifile.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="7.9.2 multifile Example"
  href="multifile-example.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-multifile.html">7.9 multifile  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-multifile.html">7.9 multifile  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="multifile-example.html">7.9.2 MultiFile Example</a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h2><a name="SECTION009910000000000000000"></a><a name="MultiFile-objects"></a>
<br>
7.9.1 MultiFile Objects 
</h2>

<p>
A <tt class="class">MultiFile</tt> instance has the following methods:

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1547' xml:id='l2h-1547' class="method">readline</tt></b>(</nobr></td>
  <td><var>str</var>)</td></tr></table></dt>
<dd>
Read a line.  If the line is data (not a section-divider or end-marker
or real EOF) return it.  If the line matches the most-recently-stacked
boundary, return <code>''</code> and set <code>self.last</code> to 1 or 0 according as
the match is or is not an end-marker.  If the line matches any other
stacked boundary, raise an error.  On encountering end-of-file on the
underlying stream object, the method raises <tt class="exception">Error</tt> unless
all boundaries have been popped.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1548' xml:id='l2h-1548' class="method">readlines</tt></b>(</nobr></td>
  <td><var>str</var>)</td></tr></table></dt>
<dd>
Return all lines remaining in this part as a list of strings.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1549' xml:id='l2h-1549' class="method">read</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Read all lines, up to the next section.  Return them as a single
(multiline) string.  Note that this doesn't take a size argument!
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1550' xml:id='l2h-1550' class="method">seek</tt></b>(</nobr></td>
  <td><var>pos</var><big>[</big><var>, whence</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Seek.  Seek indices are relative to the start of the current section.
The <var>pos</var> and <var>whence</var> arguments are interpreted as for a file
seek.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1551' xml:id='l2h-1551' class="method">tell</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Return the file position relative to the start of the current section.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1552' xml:id='l2h-1552' class="method">next</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Skip lines to the next section (that is, read lines until a
section-divider or end-marker has been consumed).  Return true if
there is such a section, false if an end-marker is seen.  Re-enable
the most-recently-pushed boundary.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1553' xml:id='l2h-1553' class="method">is_data</tt></b>(</nobr></td>
  <td><var>str</var>)</td></tr></table></dt>
<dd>
Return true if <var>str</var> is data and false if it might be a section
boundary.  As written, it tests for a prefix other than <code>'-</code><code>-'</code> at
start of line (which all MIME boundaries have) but it is declared so
it can be overridden in derived classes.

<p>
Note that this test is used intended as a fast guard for the real
boundary tests; if it always returns false it will merely slow
processing, not cause it to fail.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1554' xml:id='l2h-1554' class="method">push</tt></b>(</nobr></td>
  <td><var>str</var>)</td></tr></table></dt>
<dd>
Push a boundary string.  When a decorated version of this boundary 
is found as an input line, it will be interpreted as a section-divider 
or end-marker (depending on the decoration, see <a class="rfc" id='rfcref-99697' xml:id='rfcref-99697'
href="http://www.faqs.org/rfcs/rfc2045.html">RFC 2045</a>).  All subsequent
reads will return the empty string to indicate end-of-file, until a
call to <tt class="method">pop()</tt> removes the boundary a or <tt class="method">next()</tt> call
reenables it.

<p>
It is possible to push more than one boundary.  Encountering the
most-recently-pushed boundary will return EOF; encountering any other
boundary will raise an error.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1555' xml:id='l2h-1555' class="method">pop</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Pop a section boundary.  This boundary will no longer be interpreted
as EOF.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1556' xml:id='l2h-1556' class="method">section_divider</tt></b>(</nobr></td>
  <td><var>str</var>)</td></tr></table></dt>
<dd>
Turn a boundary into a section-divider line.  By default, this
method prepends <code>'-</code><code>-'</code> (which MIME section boundaries have) but
it is declared so it can be overridden in derived classes.  This
method need not append LF or CR-LF, as comparison with the result
ignores trailing whitespace. 
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1557' xml:id='l2h-1557' class="method">end_marker</tt></b>(</nobr></td>
  <td><var>str</var>)</td></tr></table></dt>
<dd>
Turn a boundary string into an end-marker line.  By default, this
method prepends <code>'-</code><code>-'</code> and appends <code>'-</code><code>-'</code> (like a
MIME-multipart end-of-message marker) but it is declared so it can be
overridden in derived classes.  This method need not append LF or
CR-LF, as comparison with the result ignores trailing whitespace.
</dl>

<p>
Finally, <tt class="class">MultiFile</tt> instances have two public instance variables:

<p>
<dl><dt><b><tt id='l2h-1558' xml:id='l2h-1558' class="member">level</tt></b></dt>
<dd>
Nesting depth of the current part.
</dl>

<p>
<dl><dt><b><tt id='l2h-1559' xml:id='l2h-1559' class="member">last</tt></b></dt>
<dd>
True if the last end-of-file was for an end-of-message marker. 
</dl>

<p>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="7.9 multifile  "
  href="module-multifile.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="7.9 multifile  "
  href="module-multifile.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="7.9.2 multifile Example"
  href="multifile-example.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-multifile.html">7.9 multifile  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-multifile.html">7.9 multifile  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="multifile-example.html">7.9.2 MultiFile Example</a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
